//
//  MessageListCell.m
//  Doctor
//
//  Created by 阳光 on 16/9/13.
//  Copyright © 2016年 阳光. All rights reserved.
//

#import "MessageListCell.h"

@interface MessageListCell ()

@property(nonatomic,strong)UIView *bgView;

// 消息title
@property(nonatomic,strong)UILabel *titleLabel;

// 消息detail
@property(nonatomic,strong)UILabel *detailLabel;

// 时间
@property(nonatomic,strong)UILabel *timeLabel;

@property(nonatomic,strong)CustomButton *detailBtn;

@property(nonatomic,strong)UIView *midLine;


@end

@implementation MessageListCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor=MAIN_BACK_COLOR;
        self.bgView.hidden=NO;
        self.titleLabel.font=Font_Number(16);
        self.detailLabel.font=Font_Number(16);
        self.timeLabel.font=Font_Number(16);
        self.midLine.hidden=NO;
        self.detailBtn.hidden=NO;
    };
    return self;
}

-(UIView *)bgView
{
    if (_bgView==nil) {
        _bgView=[UIView new];
        [self.contentView addSubview:_bgView];
        [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.mas_equalTo(kmargin);
            make.right.mas_equalTo(-kmargin);
            make.bottom.mas_equalTo(0);
        }];
        _bgView.backgroundColor=WhiteColor;
    }
    return _bgView;
}

// titleLabel
-(UILabel *)titleLabel
{
    if (!_titleLabel) {
        _titleLabel=[self getLabelWithText:@"第六次中华医学讨论会盛大开幕" font:Font_Number(16) textColor:Color000000 textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.bgView addSubview:_titleLabel];
        [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.mas_equalTo(kmargin);
            make.right.mas_equalTo(-kmargin);
        }];
    }
    return _titleLabel;
}

// enameLabel
-(UILabel *)detailLabel
{
    if (!_detailLabel) {
        _detailLabel=[self getLabelWithText:@"中华医学会全国医学学术会议于2016年8月16～19日在上海召开" font:Font_Number(14) textColor:Color666666 textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:0];
        [self.bgView addSubview:_detailLabel];
        [_detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.titleLabel.mas_left);
            make.right.mas_equalTo(-kmargin);
            make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(kmargin/2);
        }];
    }
    return _detailLabel;
}

-(UIView *)midLine
{
    if (_midLine==nil) {
        _midLine=[UIView new];
        [self.bgView addSubview:_midLine];
        [_midLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-kmargin);
            make.top.mas_equalTo(self.detailLabel.mas_bottom).offset(kmargin);
            make.left.mas_equalTo(self.detailLabel.mas_left);
            make.height.mas_equalTo(.5);
        }];
        _midLine.backgroundColor=ColorE5E5E5;
    }
    return _midLine;
}

// timeLabel
-(UILabel *)timeLabel
{
    if (!_timeLabel) {
        _timeLabel=[self getLabelWithText:@"12:23" font:Font_Number(13) textColor:Color999999 textAlignment:NSTextAlignmentRight lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.bgView addSubview:_timeLabel];
        [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.midLine.mas_bottom).offset(kmargin);
            make.left.mas_equalTo(kmargin);
        }];
    }
    return _timeLabel;
}

-(CustomButton *)detailBtn
{
    if (!_detailBtn) {
        _detailBtn=[CustomButton buttonWithType:UIButtonTypeCustom];
        _detailBtn.titleLabel.font=Font_Number(14);
        [_detailBtn setTitleColor:Color000000 forState:0];
        [_detailBtn setTitle:@"查看详情" forState:0];
        [_detailBtn setImage:[UIImage imageNamed:@"cell_arrow"] forState:0];
        _detailBtn.status = FLAlignmentStatusCenter;
        [_detailBtn addTarget:self action:@selector(detailBtnEvent) forControlEvents:UIControlEventTouchUpInside];
        [self.bgView addSubview:_detailBtn];
        [_detailBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-kmargin);
            make.centerY.mas_equalTo(self.timeLabel.mas_centerY);
        }];
    }
    return _detailBtn;
}

-(void)detailBtnEvent
{
    
}


@end